package cn.edu.ldu.communityqa.communityqa.service;

import cn.edu.ldu.communityqa.communityqa.dao.AnswerDao;
import cn.edu.ldu.communityqa.communityqa.entity.Answer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AnswerService {
    private final AnswerDao answerDao;

    @Autowired
    public AnswerService(AnswerDao answerDao) {
        this.answerDao = answerDao;
    }

    public List<Answer> findAll() {
        return answerDao.findAll();
    }

    public List<Answer> findByQuestionId(Long questionId) {
        return answerDao.findByQuestionId(questionId);
    }

    public Answer findById(Long id) {
        return answerDao.findById(id);
    }

    public int save(Answer answer) {
        return answerDao.save(answer);
    }

    public int update(Answer answer) {
        return answerDao.update(answer);
    }

    public int deleteById(Long id) {
        return answerDao.deleteById(id);
    }
}
